package com.warm.mybatis.service.impl;
import java.time.LocalDateTime;
import java.util.Random;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.warm.mybatis.dao.BaseRoleDao;
import com.warm.mybatis.dao.BaseUserDao;
import com.warm.mybatis.entity.BaseRoleEntity;
import com.warm.mybatis.entity.BaseUserEntity;
import com.warm.mybatis.service.BaseRoleService;
import com.warm.mybatis.service.BaseUserService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;


@Service
public class BaseRoleServiceImpl extends ServiceImpl<BaseRoleDao, BaseRoleEntity> implements BaseRoleService {

    @Resource
    BaseUserService baseUserService;
    @Resource
    BaseRoleDao baseRoleDao;


    @Transactional
    @Override
    public void insertRoleTr() {
        BaseRoleEntity role = new BaseRoleEntity();
        int i = new Random().nextInt(10);
        role.setCode(i);
        role.setName("person" + i);
        role.setCreateTime(LocalDateTime.now());
        role.setUpdateTime(LocalDateTime.now());
        baseRoleDao.insert(role);
    }

    @Override
    public void insertRoleNoTr() {
        BaseRoleEntity role = new BaseRoleEntity();
        int i = new Random().nextInt(10);
        role.setCode(i);
        role.setName("person" + i);
        role.setCreateTime(LocalDateTime.now());
        role.setUpdateTime(LocalDateTime.now());
        baseRoleDao.insert(role);
    }
}
